/**
 * @author   Ivan Andonov
 * @email:   ivan.andonov[at]gmail[dot]com
 *
 * @require  sjs 
 * @use      sjs.Objects
 * @optional 
 **/

(function() {
	
	sjs.create('sjs.Arrays', {
		
		copyArray : function(arr) {
			var a = [];
			for (var i = 0; i < arr.length; i++) {
				a[i] = arr[i];
			}
			return a;
		},
		
		isArray : function(arr) {
			return typeof(arr) == "object" && arr.length !== null;
		},
		
		inArray : function(arr, val) {
			var result = sjs.Objects.each(
				arr,
				function(prop, value, obj) {
					if (value == val) {
						return true;
					}
				}
			);
			return result || false;
		},
		
		createPhpArray : function(arrName, arr) {
			sjs.Objects.each(
				arr,
				function(num, value, arr) {
					arr[i] = encodeURI(value).replace('&', '%26');
				}
			);
			return requestData = arrName+'[]='+arr.join('&'+arrName+'[]=');
		},
		
		indexOf : function(arr, value) {
			var len = arr.length;
			for (var i = 0; i < len; i++) {
				if (arr[i] === value) {
					return i;
				}
			}
			return null;
		}
		
	});
	
})();